gtk_file_chooser_set_use_preview_label
gtk_file_chooser_get_use_preview_label
gtk_file_chooser_get_preview_file
-gtk_file_chooser_set_extra_widget
-gtk_file_chooser_get_extra_widget
<SUBSECTION>
gtk_file_chooser_add_filter
gtk_file_chooser_remove_filter
* }
* ]|
*
- * # Adding Extra Widgets
+ * # Adding options
*
* You can add extra widgets to a file chooser to provide options
- * that are not present in the default design. For example, you
- * can add a toggle button to give the user the option to open a
- * file in read-only mode. You can use
- * gtk_file_chooser_set_extra_widget() to insert additional
- * widgets in a file chooser.
- *
- * An example for adding extra widgets:
- * |[<!-- language="C" -->
- *
- * GtkWidget *toggle;
- *
- * ...
- *
- * toggle = gtk_check_button_new_with_label ("Open file read-only");
- * gtk_widget_show (toggle);
- * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
- * }
- * ]|
- *
- * If you want to set more than one extra widget in the file
- * chooser, you can a container such as a #GtkBox or a #GtkGrid
- * and include your widgets in it. Then, set the container as
- * the whole extra widget.
+ * that are not present in the default design, by using
+ * gtk_file_chooser_add_choice(). Each choice has an identifier and
+ * a user visible label; additionally, each choice can have multiple
+ * options. If a choice has no option, it will be rendered as a
+ * check button with the given label; if a choice has options, it will
+ * be rendered as a combo box.
*/
P_("Whether to display a label with the name of the previewed file."),
TRUE,
GTK_PARAM_READWRITE));
- g_object_interface_install_property (iface,
- g_param_spec_object ("extra-widget",
- P_("Extra widget"),
- P_("Application supplied widget for extra options."),
- GTK_TYPE_WIDGET,
- GTK_PARAM_READWRITE));
g_object_interface_install_property (iface,
g_param_spec_boolean ("select-multiple",
P_("Select Multiple"),
* text entry for “Name”.
*
* This is meant to be used in save dialogs, to get the currently typed filename
- * when the file itself does not exist yet. For example, an application that
- * adds a custom extra widget to the file chooser for “file format” may want to
- * change the extension of the typed filename based on the chosen format, say,
- * from “.jpg” to “.png”.
+ * when the file itself does not exist yet.
*
* Returns: The raw text from the file chooser’s “Name” entry. Free this with
* g_free(). Note that this string is not a full pathname or URI; it is
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, folder, error);
}
-/**
- * gtk_file_chooser_set_extra_widget:
- * @chooser: a #GtkFileChooser
- * @extra_widget: widget for extra options
- *
- * Sets an application-supplied widget to provide extra options to the user.
- **/
-void
-gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
- GtkWidget *extra_widget)
-{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-
- g_object_set (chooser, "extra-widget", extra_widget, NULL);
-}
-
-/**
- * gtk_file_chooser_get_extra_widget:
- * @chooser: a #GtkFileChooser
- *
- * Gets the current extra widget; see
- * gtk_file_chooser_set_extra_widget().
- *
- * Returns: (nullable) (transfer none): the current extra widget, or %NULL
- **/
-GtkWidget *
-gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
-{
- GtkWidget *extra_widget;
-
- g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
-
- g_object_get (chooser, "extra-widget", &extra_widget, NULL);
-
- /* Horrid hack; g_object_get() refs returned objects but
- * that contradicts the memory management conventions
- * for accessors.
- */
- if (extra_widget)
- g_object_unref (extra_widget);
-
- return extra_widget;
-}
-
/**
* gtk_file_chooser_add_filter:
* @chooser: a #GtkFileChooser
* a value using gtk_file_chooser_set_choice() before the dialog is shown,
* and you can obtain the user-selected value in the ::response signal handler
* using gtk_file_chooser_get_choice().
- *
- * Compare gtk_file_chooser_set_extra_widget().
*/
void
gtk_file_chooser_add_choice (GtkFileChooser *chooser,
GDK_AVAILABLE_IN_ALL
GFile *gtk_file_chooser_get_preview_file (GtkFileChooser *chooser);
-/* Extra widget
- */
-GDK_AVAILABLE_IN_ALL
-void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
- GtkWidget *extra_widget);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
-
/* List of user selectable filters
*/
GDK_AVAILABLE_IN_ALL
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
* used. It supports many of the features that #GtkFileChooserDialog
* does, but there are some things it does not handle:
*
- * * Extra widgets added with gtk_file_chooser_set_extra_widget().
- *
* * Use of custom previews by connecting to #GtkFileChooser::update-preview.
*
* * Any #GtkFileFilter added using a mimetype or custom filter.
* be a GTK+ file chooser. In this situation, the following things are not
* supported and will be silently ignored:
*
- * * Extra widgets added with gtk_file_chooser_set_extra_widget().
- *
* * Use of custom previews by connecting to #GtkFileChooser::update-preview.
*
* * Any #GtkFileFilter added with a custom filter.
* file chooser dialogs. Some features provided by #GtkFileChooserDialog are
* not supported:
*
- * * Extra widgets added with gtk_file_chooser_set_extra_widget(), unless the
- * widget is an instance of GtkLabel, in which case the label text will be used
- * to set the NSSavePanel message instance property.
- *
* * Use of custom previews by connecting to #GtkFileChooser::update-preview.
*
* * Any #GtkFileFilter added with a custom filter.
guint update_preview_signal;
GSList *filters, *l;
int n_filters, i;
- GtkWidget *extra_widget = NULL;
char *message = NULL;
- extra_widget = gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self));
- // if the extra_widget is a GtkLabel, then use its text to set the dialog message
- if (extra_widget != NULL)
- {
- if (!GTK_IS_LABEL (extra_widget))
- return FALSE;
- else
- message = g_strdup (gtk_label_get_text (GTK_LABEL (extra_widget)));
- }
-
update_preview_signal = g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER);
if (g_signal_has_handler_pending (self, update_preview_signal, 0, TRUE))
return FALSE;
GSList *filters, *l;
int n_filters, i;
- if (gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self)) != NULL &&
- self->choices == NULL)
- return FALSE;
-
update_preview_signal = g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER);
if (g_signal_has_handler_pending (self, update_preview_signal, 0, TRUE))
return FALSE;
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_ACTION,
"action");
- g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET,
- "extra-widget");
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_FILTER,
"filter");
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE,
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL,
- GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET,
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN,
GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION,
update_preview_widget_visibility (impl);
break;
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
- set_extra_widget (impl, g_value_get_object (value));
- break;
-
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
{
gboolean select_multiple = g_value_get_boolean (value);
g_value_set_boolean (value, priv->use_preview_label);
break;
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
- g_value_set_object (value, priv->extra_widget);
- break;
-
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
g_value_set_boolean (value, priv->select_multiple);
break;
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton)));
}
-static void
-native_extra_widget_toggle (GtkWidget *checkbutton,
- GtkFileChooserNative *native)
-{
- gboolean extra_widget = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton));
-
- if (extra_widget)
- {
- GtkWidget *extra = gtk_check_button_new_with_label ("Extra toggle");
- gtk_widget_show (extra);
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (native), extra);
- }
- else
- {
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (native), NULL);
- }
-}
-
-
static void
native_visible_notify_show (GObject *object,
GParamSpec *pspec,
G_CALLBACK (native_overwrite_confirmation_toggle), native);
gtk_container_add (GTK_CONTAINER (box), check_button);
- check_button = gtk_check_button_new_with_label ("Extra widget");
- g_signal_connect (check_button, "toggled",
- G_CALLBACK (native_extra_widget_toggle), native);
- gtk_container_add (GTK_CONTAINER (box), check_button);
-
show_button = gtk_button_new_with_label ("Show");
hide_button = gtk_button_new_with_label ("Hide");
gtk_widget_set_sensitive (hide_button, FALSE);